package no.sachmuld.methodcombination.examples.reflection.combo.foo;

import no.sachmuld.methodcombination.api.CrosscuttingBehaviour;
import no.sachmuld.methodcombination.api.BehaviourChain;
import no.sachmuld.methodcombination.api.reflection.Or;
import no.sachmuld.methodcombination.examples.reflection.combo.SimpleCrosscutting;
import no.sachmuld.methodcombination.examples.reflection.combo.StandardCrosscutting;

/**
 *
 */
public abstract class Foo {

    final private BehaviourChain<CrosscuttingBehaviour> chain = new BehaviourChain<>();

    final public String bar(int i) {
        return new StandardCrosscutting<CrosscuttingBehaviour, String>().build(FooBehaviour.class, Foo.class, "bar", Integer.TYPE).execute(this, chain, i);
    }

    final public String baz(int i) {
        return new StandardCrosscutting<CrosscuttingBehaviour, String>().build(FooBehaviour.class, Foo.class, "baz", Integer.TYPE).execute(this, chain, i);
    }

    final public boolean or() {
        return new SimpleCrosscutting<CrosscuttingBehaviour, Boolean>(new Or()).build(FooBehaviour.class, Foo.class, "or").execute(this, chain);
    }


    final protected Foo with(CrosscuttingBehaviour... behaviours) {
        chain.addAll(behaviours);
        return this;
    }

}
